package com.sunny.blog.service.impl;

import com.sunny.blog.service.FileService;
import com.sunny.blog.util.FastDFSClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @ClassName: FileServiceImpl
 * @Description:
 * @Author: sunt
 * @Date: 2020/4/17 15:40
 * @Version 1.0
 **/
@Service
@Slf4j
public class FileServiceImpl  implements FileService {

    @Autowired
    private FastDFSClient fastDFSClient;

    @Override
    public String uploadFdfsFile(MultipartFile file) throws IOException {
       /* byte[] bytes = file.getBytes();
        //获取源文件名称
        String originalFileName = file.getOriginalFilename();
        //获取文件后缀--.doc
        String extension = originalFileName.substring(originalFileName.lastIndexOf(".") + 1);
        String fileName = file.getName();
        //获取文件大小
        long fileSize = file.getSize();*/
        return fastDFSClient.upload(file);
    }

    @Override
    public void downloadFile(String fileUrl, HttpServletResponse response) {

    }
}
